#include <bits/stdc++.h>

using namespace std;

//https://leetcode-cn.com/circle/discuss/MwNNcS/
/**
 * 只想到暴力？？？ 
 */
class Solution {
public:
    int C[7][7];
    Solution(){
        int i, j,m=6,n=6;
        for(i = 1; i <= m; i++) { 
            for(j = 0; j <= i && j <= n; j++) { 
                if(j == 0 || j == i)
                    C[i][j] = 1;
                else
                    C[i][j] = C[i-1][j-1] + C[i-1][j];
            }
        }
    }

    int paintingPlan(int n, int k) {
        if(k==n*n||k==0){
            return 1;
        }
        int ans=0;
        for(int i=0;i<=n;i++){
            for(int j=0;j<=n;j++){
                if(n*(i+j)-(i*j)==k){
                    ans+=C[n][i]*C[n][j];
                }
            }
        }
        return ans;
    }
};



int main(){
    Solution s;

    cout << s.paintingPlan(2,4) << endl;

    return 0;
}